package com.zwps.biz.domain.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zwps.biz.api.model.vo.structure.ZEquityStruVO;
import com.zwps.biz.api.model.vo.structure.ZEquityVO;
import com.zwps.biz.dal.db.dao.ZEquityDAO;
import com.zwps.biz.dal.db.object.ZEquityDO;
import com.zwps.biz.domain.service.ZEquityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 *
 */
@DS("lhk")
@Service
public class ZEquityServiceImpl extends ServiceImpl<ZEquityDAO, ZEquityDO>
        implements ZEquityService {
    @Autowired
    private ZEquityDAO zEquityDAO;

    @Override
    public ZEquityStruVO getEquity() {
        ZEquityStruVO equityVO = zEquityDAO.count();
        List<ZEquityVO> zEquityVOS = this.list(new LambdaQueryWrapper<ZEquityDO>().eq(ZEquityDO::getIsDelete,0)).stream().map(zEquityDO -> {
            ZEquityVO zEquityVO = new ZEquityVO();
            BeanUtil.copyProperties(zEquityDO, zEquityVO);
            return zEquityVO;
        }).collect(Collectors.toList());
        equityVO.setList(zEquityVOS);
        return equityVO;
    }
}




